<?php
if(!isset($_SESSION)) {
  session_start();
}
if (!isset($indexMode) || $indexMode != true) {
  include_once '../library/config.php';
  include_once '../library/query.php';
  include_once '../library/utils.php';
  //include_once '../library/ftp.php';
  header('Content-Type: text/html; charset=utf-8');  
}

//Instance the Database Class
$db = new db_class();
if (!$db->connect($CONFIG_host, $CONFIG_user, $CONFIG_pass, $CONFIG_db)) {
  die("Erro ao acessar o banco de dados!");
}
if (!$db->select_db()){
  die("Banco de dados não encontrado!");
}

//URL treatment
$service = $GET_service;
if (!$service || empty($service)) {
  //$GET_service = "main";
  die ("<script>window.location='../?'</script>");
} elseif($service == "getIP") {
  die ($_SERVER['REMOTE_ADDR']);
} elseif(preg_match("/http|ftp|https|www|wget/", $service) || !(is_file($service.".php") || is_file("services/".$service.".php"))) {
  die ("<script>window.location='../?'</script>");
} 
include ($service.'.php');
?>
